#include <bits/stdc++.h>

using namespace std;
const int maxn = 10;
int book[maxn];
int a[maxn];
int n = 3;

void dfs(int k) {
    if (k >= n) {
        for (int i = 0; i < n; i++)cout << a[i];
        cout << endl;
        return;
    }
    for (int i = 0; i < n; i++) {
        if (book[i] == 1)continue;
        book[i] = 1;
        a[k] = i + 1;
        dfs(k + 1);
        book[i] = 0;
    }

}

int main() {

    dfs(0);
}
